package com.demo.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.demo.dto.EasyUIGrid;
import com.demo.dto.EasyUIPage;
import com.demo.entity.Post;
import com.demo.mapper.PostMapper;
import com.demo.service.PostService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service
@Transactional
public class PostServiceImpl extends AbstractBaseService<Post> implements PostService {

	@Resource
	private PostMapper postMapper;
	
	public EasyUIGrid findByParams(EasyUIPage easyUIPage, Map<String,String> params) {
		EasyUIGrid easyUIGrid = new EasyUIGrid();
		Page<Object> page = PageHelper.startPage(easyUIPage.getPage(), easyUIPage.getRows());
		List<Post> dutys = postMapper.findByParams(params);
		easyUIGrid.setRows(dutys);
		easyUIGrid.setTotal(page.getTotal());
		return easyUIGrid;
	}
}
